/*
package com.frank.statisticsInterface;

import java.util.Date;

*/
/**
 * @author 小石潭记
 * @date 2020/11/6 17:10
 * @Description: ${todo}
 *//*

public class RestApiInvokeStatus {
    private String name;
    private Date startDate;
    private Date latestDate;
    private long times;
    private float averageDuration;
    private int minDuration;
    private int maxDuration;
    private int[] durations;

    public String getName() {
        return name;
    }

    public Date getStartDate() {
        return startDate;
    }

    public Date getLatestDate() {
        return latestDate;
    }

    public long getTimes() {
        return times;
    }

    public int getMinDuration() {
        return minDuration;
    }


    public int getMaxDuration() {
        return maxDuration;
    }

    public RestApiInvokeStatus(String name) {
        Assert.isNotBlank(name, "name");

        this.name = name;
        this.durations = new int[1000];
        this.minDuration = Integer.MAX_VALUE;
        this.maxDuration = Integer.MIN_VALUE;
        Date now = new Date();
        this.startDate = now;
        this.latestDate = now;

    }

    public void setDuration(int duration) {
        this.durations[(int) (this.times % this.durations.length)] = duration;
        this.maxDuration = this.maxDuration > duration ? this.maxDuration : duration;
        this.minDuration = this.minDuration < duration ? this.minDuration : duration;
        this.latestDate = new Date();
        this.times++;
    }

    public float getAverageDuration() {
        long length = this.times < this.durations.length ? this.times : this.durations.length;

        int count = 0;
        for (int i = 0; i < length; i++) {
            count += this.durations[i];
        }
        this.averageDuration = (float) count / (float) length;

        return this.averageDuration;
    }
}
*/
